In a conventional Motion Picture Experts Group-4 (MPEG-4) media coding system, a set of quantized discrete cosine transform (DCT) coefficients comprises three DCT coefficients “run”, “level” and “last”, represented in format of (run, level, last), and is encoded with a variable length coding (VLC) approach. Generally, the VLC approach adopts a VLC table to encode a set of the quantized DCT coefficients (run, level, last).
In practice, the VLC table has two types—an intra-coded table and an inter-coded table. The intra-coded table is adopted to encode two macro-blocks in a same frame when two adjacent frames in a video stream have no approximate macro-blocks. The inter-frame coding table is adopted to encode two macro-blocks of adjacent frames when two adjacent frames in the video stream have at least one approximate macro-block.
Reference is made to FIG. 1, which is a schematic diagram of relative relationship of application scopes between the VLC table and three other VLC modes. As shown in FIG. 1, since the number of sets of quantized DCT coefficients defined in the VLC table is limited, except the set of the quantized DCT coefficients (run, level, last) defined in the predetermined VLC table, other sets of quantized DCT coefficients are respectively adopted in three types of escape coding modes Type 1, Type 2 and Type 3. Type 3, a fixed-length escape coding mode, has a widest application scope that covers all sets of quantized DCT coefficients. Type 1, an escape coding mode for coefficient “level”, and Type 2, an escape coding mode for coefficient “run”, are respectively applicable to a portion of the sets of quantized DCT coefficients. Please note that the application scope of Type 1 and that of Type 2 are partly overlapped. As can be seen from a scope A in FIG. 1, the sets of quantized DCT coefficients within the scope A are adopted for encoding in both Type 1 and Type 2.
Reference is made to FIG. 2, which is a flowchart of a conventional media coding system performing encoding of a set of quantized coefficients. In Step S10, the process determines whether the set of quantized coefficients is defined in a predetermined VLC table. When a determination result of Step S10 is positive, the process proceeds to Step S11, in which the set of quantized coefficients is directly encoded according to the predetermined VLC table. When the determination result of Step S10 is negative, which means the predetermined VLC table does not comprise coding information of the set of the quantized coefficients, the set of quantized coefficients cannot be encoded with the predetermined VLC table.
The process proceeds to Step S12, for determining whether the first VLC mode Type 1 is applicable to the set of quantized coefficients. When a determination result of Step S12 is positive, the process proceeds to Step S13, in which the set of quantized coefficients is encoded according to the first VLC mode. When the determination result of Step S12 is negative, the process proceeds to Step S14, for determining whether the second VLC mode (Type 2) is applicable to the set of quantized coefficients. When a determination result of Step S14 is positive, the process proceeds to Step S15, in which the set of quantized coefficients is encoded according to the second VLC mode. Since the third VLC mode Type 3 is applicable to all sets of quantized coefficients, if the determination result of Step S14 is negative, the process proceeds to Step S16 in which the set of quantized coefficients is encoded according to the third VLC mode Type 3.
It is noted that the execution sequence of Step S12, for determining whether the first VLC mode is applicable to the set of quantized coefficients, and Step S14, for determining whether the second VLC mode is applicable to the set of quantized coefficients, can be exchanged. That is, the determination sequence of Type 1 and Type 2 is not limited; however, the exchange of sequence may lead to different determination results.
However, for sets of quantized coefficients adopted in both of the VLC modes Type 1 and Type 2 (i.e., the sets of quantized coefficients covered by the scope A in FIG. 1), a non-best coding mode may be selected from the VLC modes Type 1 and Type 2 when the above approach is adopted; i.e., a coding length obtained from encoding the set of quantized coefficients according to the non-best coding mode is not the shortest coding length, thereby the best coding efficiency cannot be achieved.
For example, supposing that the set of quantized DCT coefficients (run, level, last) is (2, 8, 0), which is adopted in both of the VLC modes Type 1 and Type 2 and defined in the intra-coded table. According to the prior art, Type 1 is selected to encode the set of quantized DCT coefficients to obtain a coding result of “0000011, 0, 000011110s” having a coding length of 18 bits. However, in practice, when Type 2 is adopted to encode the set of quantized DCT coefficients, the coding result is “0000011, 10, 010011s”, having a coding length of only 16 bits.
As can be seen from the above, when a coding mode is selected according to the prior art to encode a set of quantized DCT coefficients, the obtained coding result may not have the shortest coding length, thereby the best coding efficiency cannot be achieved. In addition, when the best coding mode is selected by the above rules, it not only cannot ensure the best coding mode, but also extremely complicates software and hardware of the conventional media coding system and thereby results in increase of practical production cost.
Therefore, one main object of the present invention is to provide a media coding system, a quantized coefficient coding apparatus and a quantized coefficient coding method to solve the above problem.